import 'package:floor/floor.dart';

@entity
class UserEntity {
  @primaryKey
   int? id;

   String? phone;

   int? positionId;

   String? nickname;

   String? avatar;

   String? email;

   int? createAt;

  UserEntity(this.id, this.phone, this.positionId, this.nickname, this.avatar,
      this.email, this.createAt);

  UserEntity.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    phone = json['phone'];
    positionId = json['position_id'];
    nickname = json['nickname'];
    avatar = json['avatar'];
    email = json['email'];
    createAt = json['createAt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['phone'] = this.phone;
    data['position_id'] = this.positionId;
    data['nickname'] = this.nickname;
    data['avatar'] = this.avatar;
    data['email'] = this.email;
    data['createAt'] = this.createAt;
    return data;
  }

  static List<UserEntity> fromJsonList(List<dynamic> jsonList) {
    return jsonList.map((json) => UserEntity.fromJson(json)).toList();
  }
}